package com.powerhua.privilege.dao.ibatis;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.powerhua.privilege.dao.UserDao;
import com.powerhua.privilege.domain.User;

public class UserDaoImpl extends SqlMapClientDaoSupport implements UserDao {

	public List getUserList(int start, int offset) throws DataAccessException{
		List list = getSqlMapClientTemplate().queryForList("getUserList", null, start, offset);
		return list;
	}

	public int deleteUser(User user) throws DataAccessException{
		int result = getSqlMapClientTemplate().delete("deleteUserById", user.getUserId());
		return result;
	}

	public User findUserById(String userId) throws DataAccessException{	
		return (User)getSqlMapClientTemplate().queryForObject("getUserById", userId);
	}

	public int insertUser(User user) throws DataAccessException{
		getSqlMapClientTemplate().insert("insertUser", user);
		return 0;
	}

	public int updateUser(User user) throws DataAccessException {
		getSqlMapClientTemplate().update("updateUser", user);
		return 0;
	}

	public User findUserByName(String userName) throws DataAccessException {
		return (User)getSqlMapClientTemplate().queryForObject("getUserByName", userName);
	}

	public boolean loginCheck(String userName, String userPassword) throws DataAccessException {
		// TODO Auto-generated method stub
		return false;
	}

}
